/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package entitybean;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 *
 * @author Admin
 */
@Entity
@Table(name = "promotions", catalog = "OnlineShopFourDVD", schema = "dbo")
@NamedQueries({
    @NamedQuery(name = "Promotions.findAll", query = "SELECT p FROM Promotions p"),
    @NamedQuery(name = "Promotions.findByPromotionId", query = "SELECT p FROM Promotions p WHERE p.promotionsPK.promotionId = :promotionId"),
    @NamedQuery(name = "Promotions.findByMediaId", query = "SELECT p FROM Promotions p WHERE p.promotionsPK.mediaId = :mediaId"),
    @NamedQuery(name = "Promotions.findByPriceDown", query = "SELECT p FROM Promotions p WHERE p.priceDown = :priceDown"),
    @NamedQuery(name = "Promotions.findByStartdate", query = "SELECT p FROM Promotions p WHERE p.startdate = :startdate"),
    @NamedQuery(name = "Promotions.findByEnddate", query = "SELECT p FROM Promotions p WHERE p.enddate = :enddate")})
public class Promotions implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected PromotionsPK promotionsPK;
    @Column(name = "price_down")
    private Integer priceDown;
    @Column(name = "startdate")
    @Temporal(TemporalType.TIMESTAMP)
    private Date startdate;
    @Column(name = "enddate")
    @Temporal(TemporalType.TIMESTAMP)
    private Date enddate;
    @JoinColumn(name = "media_id", referencedColumnName = "media_id", nullable = false, insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Media media;

    public Promotions() {
    }

    public Promotions(PromotionsPK promotionsPK) {
        this.promotionsPK = promotionsPK;
    }

    public Promotions(int promotionId, int mediaId) {
        this.promotionsPK = new PromotionsPK(promotionId, mediaId);
    }

    public PromotionsPK getPromotionsPK() {
        return promotionsPK;
    }

    public void setPromotionsPK(PromotionsPK promotionsPK) {
        this.promotionsPK = promotionsPK;
    }

    public Integer getPriceDown() {
        return priceDown;
    }

    public void setPriceDown(Integer priceDown) {
        this.priceDown = priceDown;
    }

    public Date getStartdate() {
        return startdate;
    }

    public void setStartdate(Date startdate) {
        this.startdate = startdate;
    }

    public Date getEnddate() {
        return enddate;
    }

    public void setEnddate(Date enddate) {
        this.enddate = enddate;
    }

    public Media getMedia() {
        return media;
    }

    public void setMedia(Media media) {
        this.media = media;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (promotionsPK != null ? promotionsPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Promotions)) {
            return false;
        }
        Promotions other = (Promotions) object;
        if ((this.promotionsPK == null && other.promotionsPK != null) || (this.promotionsPK != null && !this.promotionsPK.equals(other.promotionsPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entitybean.Promotions[promotionsPK=" + promotionsPK + "]";
    }

}
